<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>信息录入</title>
        <meta name="viewport" content="width=device-width,initial-scale=1">
        <link rel="stylesheet" href="drive_information.css">
        <link rel="stylesheet" href="normalize.css">
        <link rel="stylesheet" href="../public_css/public_header.css">
    </head>
    <body>
        <header class=" public_header">
            <div class="public_header_return">
                <img src="../public_img/return.png" alt="" class="public_header_return" onclick="history.back(-1)">
                <p>提交材料</p>
            </div>
        </header>
        <section class="mainbody">
            <form class="information_collect" id="information_collect1">
                <!--<span>取件地址:</span>
<input class="message_input" type="text" id="address">-->
                <br/>
                <span>暂住证:</span>
                <!-- <input class="message_input" type="text"> -->
                <select class="message_input"  value="" id="message">
                    <option>需要</option>
                    <option>不需要</option>
                </select>
                <br/>
                <form class="file_view">
                    <label for="file_input">
                        <div id="fileList" class="fileList1"></div>
                        <input type="file" id="file_input"  name="file"  class="file_input1" multiple accept="image/*"  style="display: none">
                    </label>
                    <p class="idCard" name="btn2">身份证复印件</p>
                </form>
                <br/>

                <form class="file_view">
                    <label for="file_input2">
                        <div id="fileList2"  class="fileList1"></div>
                        <input type="file" id="file_input2" name="file" class="file_input1" multiple accept="image/*">
                    </label>
                    <p class="idCard" name="btn2" >一寸白底照片</p>
                </form>
                <br/>

                <form class="file_view">
                    <label for="file_input3">
                        <div id="fileList3" class="fileList1"></div>
                        <input type="file" id="file_input3" name="file" class="file_input1" multiple accept="image/*">
                    </label>
                    <p class="idCard" name="btn2" >照相馆拍照上传回执单</p>
                </form>
                <br/>

                <form class="file_view">
                    <label for="file_input4">
                        <div id="fileList4" class="fileList1"></div>
                        <input type="file" id="file_input4" name="file" class="file_input1" multiple accept="image/*">
                    </label>
                    <p class="idCard" name="btn2" >体检单</p>
                </form>
                <br/>

                <form class="file_view">
                    <label for="file_input5">
                        <div id="fileList5" class="fileList1"></div>
                        <input type="file" id="file_input5" name="file"  class="file_input1" multiple accept="image/*">
                    </label>
                    <p class="idCard" name="btn2" >居住证明(外地户口)</p>
                </form>
                <br/>
                <input class="contact_server" type="button" value="联系客服" onclick="window.location.href='tel:15680509893'">
                <input class="submit_final" type="button" value="上传">
            </form>
        </section>
        <script src="../info/jquery.min.js"></script>
        <script src="picturefill.js"></script>
        <script src="index.js"></script>
        <script src="../layer.js"></script>
        <script type="text/javascript">
            $(".submit_final").click(function(){
                var token = localStorage.phone;
                var file_input = $("#file_input").val();
                var file_input2 = $("#file_input2").val();
                var file_input3 = $("#file_input3").val();
                var file_input4 = $("#file_input4").val();
                var file_input5 = $("#file_input5").val();
                if(file_input=='' || file_input2=='' || file_input3=='' || file_input4=='' || file_input5==''){
                    layer.msg("请填写完整信息");
                    return false;
                }
                var message = $("#message").val();
                $.ajax({
                    url:'https://newapp.icandrive.cn/api/exam_site.php',
                    dataType:'json',
                    type:'post',
                    data:{token:token,message:message},
                    success:function(data){
                        if(data.status==250){
                            layer.msg("请重新登录");
                            setInterval(function(){
                                window.location.href="../login/log_in.html";
                            },2000);
                        }
                        if(data.status==200){
                            layer.msg("提交成功");
                        }
                        if(data.status==400){
                            layer.msg("提交失败");
                        }
                    },
                    error:function(){
                        layer.msg('系统维护中',function(){
                            history.go(0)
                        },1000);
                    }
                });
            });
            $(function () {
                $('#file_input').click();
                $('#file_input').change(function () {
                    UpladFile();
                })
            });
            var xhr;
            var token = localStorage.phone;
            function createXMLHttpRequest() {
                if (window.ActiveXObject) {
                    xhr = new ActiveXObject("Microsoft.XMLHTTP");
                } else if (window.XMLHttpRequest) {
                    xhr = new XMLHttpRequest();
                }
            }
            function UpladFile() {

                var fileObj = document.getElementById("file_input").files[0];
                var FileController = 'https://newapp.icandrive.cn/api/ID_img.php?token='+token;
                var form = new FormData();
                form.append("myfile", fileObj);
                createXMLHttpRequest();
                xhr.onreadystatechange = handleStateChange;
                xhr.open("post", FileController, true);
                xhr.send(form);
            }

            function handleStateChange() {
                if (xhr.readyState == 4) {
                    if (xhr.status == 200 || xhr.status == 0) {
                        var result = xhr.responseText;
                        var json = eval("(" + result + ")");
                    }
                }
            }
            //  上传user_img
            $(function () {
                $('#file_input2').click();
                $('#file_input2').change(function () {
                    UpladFile1();
                })
            });
            function UpladFile1() {

                var fileObj = document.getElementById("file_input2").files[0];
                var FileController = 'https://newapp.icandrive.cn/api/user_img.php?token='+token;
                var form = new FormData();
                form.append("myfile", fileObj);
                createXMLHttpRequest();
                xhr.onreadystatechange = handleStateChange;
                xhr.open("post", FileController, true);
                xhr.send(form);
            }
            //live_img上传
            $(function () {
                $('#file_input3').click();
                $('#file_input3').change(function () {
                    UpladFile2();
                })
            });
            function UpladFile2() {

                var fileObj = document.getElementById("file_input3").files[0];
                var FileController = 'https://newapp.icandrive.cn/api/live_img.php?token='+token;
                var form = new FormData();
                form.append("myfile", fileObj);
                createXMLHttpRequest();
                xhr.onreadystatechange = handleStateChange;
                xhr.open("post", FileController, true);
                xhr.send(form);
            }
            //check_img上传
            $(function () {
                $('#file_input4').click();
                $('#file_input4').change(function () {
                    UpladFile3();
                })
            });
            function UpladFile3() {

                var fileObj = document.getElementById("file_input4").files[0];
                var FileController = 'https://newapp.icandrive.cn/api/check_img.php?token='+token;
                var form = new FormData();
                form.append("myfile", fileObj);
                createXMLHttpRequest();
                xhr.onreadystatechange = handleStateChange;
                xhr.open("post", FileController, true);
                xhr.send(form);
            }
            //receipt_img上传
            $(function () {
                $('#file_input5').click();
                $('#file_input5').change(function () {
                    UpladFile4();
                })
            });
            function UpladFile4() {

                var fileObj = document.getElementById("file_input5").files[0];
                var FileController = 'https://newapp.icandrive.cn/api/receipt_img.php?token='+token;
                var form = new FormData();
                form.append("myfile", fileObj);
                createXMLHttpRequest();
                xhr.onreadystatechange = handleStateChange;
                xhr.open("post", FileController, true);
                xhr.send(form);
            }
        </script>

        <script>
            document.addEventListener("plusready", function() {
                // 注册返回按键事件
                plus.key.addEventListener('backbutton', function() {
                    window.history.back();
                }, false);
                //此处false代表不退出页面，如果为true回退到上一个一面
            });
        </script>
    </body>
</html>
